/**
 * @author Jordan Barroga
 * @author Reed Pasatiempo
 */

import java.awt.Container;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.Action;

public class MainMenu 
{
	
//	public static Settings Settings = new Settings();
	
	JButton newGame, settings, scores;
	boolean settingsChanged = false;
	Settings changedSettings;
	int score, level;
	int width, height, speed, difficulty;

	public static void main(String[] args)
	{
		MainMenu main = new MainMenu();
		Scores scores = new Scores();
		Settings settings = new Settings();
	}
	
	public MainMenu()
	{
		
		JFrame jframe = new JFrame();
		JPanel mainPanel = new JPanel();	
		JPanel helpPanel = new JPanel();

		Action newGameAction = new newGameAction("New Game", null, null, 0);
		JButton newGameButton = new JButton(newGameAction);

		Action settingsAction = new changeSettings("Settings", null, null, 0);
		JButton settingsButton = new JButton(settingsAction);
		
		Action scores = new scoresWindow("Scores", null, null, 0);
		JButton scoresButton = new JButton(scores);
		
		Action help = new helpWindow("Help", null, null, 0);
		JButton helpButton = new JButton(help);
		
		Action about = new aboutWindow("About", null, null, 0);
		JButton aboutButton = new JButton(about);
		
		mainPanel.add(newGameButton);
		mainPanel.add(settingsButton);
		mainPanel.add(scoresButton);
		helpPanel.add(helpButton);
		helpPanel.add(aboutButton);
		
		jframe.setTitle("Snake Revamped!");
		jframe.setSize(300,500);	// (width, height)
		
		Container pane = jframe.getContentPane();
		
		pane.setLayout(new BorderLayout());
		jframe.add(mainPanel);
		jframe.add(helpPanel);
		jframe.getContentPane().add(mainPanel, BorderLayout.NORTH);
		jframe.getContentPane().add(helpPanel, BorderLayout.SOUTH);
		
		jframe.setDefaultCloseOperation(jframe.EXIT_ON_CLOSE);
		jframe.setVisible(true);
		
	}
	
	public class newGameAction extends AbstractAction
	{
		public newGameAction(String text, ImageIcon icon, String desc, Integer mnemonic)
		{
			super(text, icon);
			putValue(SHORT_DESCRIPTION, desc);
			putValue(MNEMONIC_KEY, mnemonic);
		}

		public void actionPerformed(ActionEvent arg0) 
		{
			if(settingsChanged == false)
			{
				new Snake(false, null);
			}
			else
			{
				new Snake(true, changedSettings);
			}
		}
	}
	
	public class changeSettings extends AbstractAction
	{
		public changeSettings(String text, ImageIcon icon, String desc, Integer mnemonic)
		{
			super(text, icon);
			putValue(SHORT_DESCRIPTION, desc);
			putValue(MNEMONIC_KEY, mnemonic);
		}
		
		public void actionPerformed(ActionEvent arg0) 
		{
			settingsChanged = true;
			SettingsMenu.createGUI();
		}
	}
	
	public class scoresWindow extends AbstractAction
	{
		public scoresWindow(String text, ImageIcon icon, String desc, Integer mnemonic)
		{
			super(text, icon);
			putValue(SHORT_DESCRIPTION, desc);
			putValue(MNEMONIC_KEY, mnemonic);
		}
		
		public void actionPerformed(ActionEvent arg0)
		{
			Scores.createGUI();
		}
	}
	
	public class helpWindow extends AbstractAction
	{
		public helpWindow(String text, ImageIcon icon, String desc, Integer mnemonic)
		{
			super(text, icon);
			putValue(SHORT_DESCRIPTION, desc);
			putValue(MNEMONIC_KEY, mnemonic);
		}
		
		public void actionPerformed(ActionEvent arg0)
		{
			HelpWindow.createGUI();
		}
		
	}
	
	public class aboutWindow extends AbstractAction
	{
		public aboutWindow(String text, ImageIcon icon, String desc, Integer mnemonic)
		{
			super(text, icon);
			putValue(SHORT_DESCRIPTION, desc);
			putValue(MNEMONIC_KEY, mnemonic);
		}
		
		public void actionPerformed(ActionEvent arg0)
		{
			AboutWindow.createGUI();
		}
		
	}
	
}
